﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CdcSoftware.Pivotal.Applications.Core.Client;
using CdcSoftware.Pivotal.Engine.UI.Forms;
using System.Windows.Forms;
using System.Security.Cryptography;
using CdcSoftware.Pivotal.Engine.Client.Services.Interfaces;
using System.Data;
using CdcSoftware.Pivotal.Engine.Types.Database;
using CdcSoftware.Pivotal.Engine.Types.MailMerges;
using CdcSoftware.Pivotal.Engine;
using CdcSoftware.Pivotal.Applications.Core.Common;

namespace Pcm.Retail.Client.FormTasks
{
    public partial class RE_Contact : FormClientTask
    {
        /// <summary>
        /// On Exit of RE_Type field.
        /// </summary>
        /// <param name="sender">The control associated with the event triggered</param>
        /// <param name="args">The argument for the event</param>
        /// <history>
        /// #Revision   Date            Author      Description
        /// 6.0.8.1     2013-03-12      AS          Initial version.
        /// </history>

        public virtual void onExitType(PivotalControl sender, EventArgs args)
        {
            try
            {
                if (this.FormView.FormName == "RE_Contact")
                {
                    if (String.Equals(TypeConvert.ToString(this.PrimaryDataRow["RE_Type"]), "Member"))
                    {
                        PivotalMessageBox.Show("Cannot set the type to Member", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        this.PrimaryDataRow["RE_Type"] = DBNull.Value;
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.HandleException(ex);
            }
        }
    }    
}
